﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class CalendarManage_HavingCalendar : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserName"] == null)
        {
            Response.Write("<script>alert('请先登录!');window.location.href='../Login.aspx'</script>");
        }
        else
        {
            Bind();
        }
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        
      
    }
    public void Bind()
    {
        string UserName = Session["UserName"].ToString();
        Sqlselete sl = new Sqlselete();
        int id=sl.SelectTeacherID(UserName);
        //int id = Convert.ToInt32(Request["id"].ToString());
        DataSet ds = new Sqlselete().MyCalendar(id);


            GridView1.DataSource = ds.Tables[0];
            GridView1.DataBind();
            this.Label1.Text = "共有" + GridView1.Rows.Count.ToString() + "条记录";

    }



    protected void Button1_Click1(object sender, EventArgs e)
    {
        
    }
    protected void GridView1_RowDeleting2(object sender, GridViewDeleteEventArgs e)
    {

        int i = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
        SqlDelete sd = new SqlDelete();
        if (sd.DeleteMyCalendar(i) > 0)
        {
            Bind();
        }
    }
    protected void GridView1_RowEditing1(object sender, GridViewEditEventArgs e)
    {
       
        string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
        Response.Write("<script>window.loaction='AddMessage.aspx?id="+id+"';</script>");
       
    }
    protected void GridView1_RowDataBound2(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
            {
                ((LinkButton)e.Row.Cells[3].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除：\"" + e.Row.Cells[0].Text + "\"的信息吗?')");
            }
        }
    }
}
